Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/store/[[...page]].tsx
5750 views
1
/*
2
* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Layout } from "antd";
7
import Error from "next/error";
8
9
import { capitalize } from "@cocalc/util/misc";
10
import Footer from "components/landing/footer";
11
import Head from "components/landing/head";
12
import Header from "components/landing/header";
13
import Store from "components/store";
14
import { StorePages } from "components/store/types";
15
import { Customize } from "lib/customize";
16
import withCustomize from "lib/with-customize";
17
18
export default function Preferences({ customize, page, pageNotFound }) {
19
const subpage = page[0] != null ? ` - ${capitalize(page[0])}` : "";
20
21
return (
22
<Customize value={customize}>
23
<Head title={`Store${subpage}`} />
24
<Layout>
25
<Header page={"store"} />
26
{pageNotFound ? <Error statusCode={404} /> : <Store page={page} />}
27
<Footer />
28
</Layout>
29
</Customize>
30
);
31
}
32
33
export async function getServerSideProps(context) {
34
let { page } = context.params;
35
if (page == null) {
36
page = [];
37
}
38
if (page.length > 0 && !StorePages.includes(page[0])) {
39
return await withCustomize({
40
context,
41
props: { pageNotFound: true, page },
42
});
43
}
44
45
return await withCustomize({ context, props: { page } });
46
}
47
48